<?php
namespace Home\Controller;
use Think\Controller;
class ActivityController extends Controller {
	

    public function index(){
    	 $options=C('options');   		 
    	$weObj = new \Org\Util\Wechat($options);
		$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
        $url = "$protocol$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
        $sign = $weObj->getJsSign($url);	
        $this->assign('arr',$sign);   
        $this->display();
    }
	 public function main(){
	 	$uid = session('uid');
		if(empty($uid)){
			$this->redirect('Jaguar/check');
		}
		$res=M('score')->where('uid='.$uid)->find();
		$fen=$res['g1_score']+$res['g2_score']+$res['g3_score']+$res['g4_score']+$res['g5_score'];
		$xg=$res['g1_status']+$res['g2_status']+$res['g3_status']+$res['g4_status']+$res['g5_status'];
		
		$this->assign('fen',$fen);  
		$this->assign('xg',$xg);  
		$this->assign('arr',$res);   	
        $this->display();
    }
	public function ewm(){
		$uid = session('uid');
		if(empty($uid)){
			$this->redirect('Jaguar/check');
		}
	
		$img='/index.php/Home/Jaguar/getEWM/uid/'.$uid;
		$this->assign('img',$img); 
        $this->display();
    }
	public function rules(){

		$id=I('id');
		$this->assign('id',$id);    
        $this->display();
    }
	
	public function paly(){
		
		
        $this->display();
    }
	public function feng(){
		$fen=I('fen');	
		saveScore(array(
				'index'	=>	4,
				'score'	=>	$fen,
			));
	$this->redirect('Activity/main');
    
    }
		public function ques(){
		$uid = session('uid');
		$res=M('user')->where('id='.$uid)->find();
		if(!empty($res['manyi'])||!empty($res['tuijian'])){
			$this->redirect('Jaguar/result');
		}
		
        $this->display();
    }
	public function quesadd(){
		$uid = session('uid');
		$q=I('q');
		$q1=I('q1');
		$res=M('user')->where('id='.$uid)->find();
		if($res){
			$data=array('manyi'=>$q,'tuijian'=>$q1);
			$re=M('user')->where('id='.$uid)->data($data)->save();
			if($re){
				$this->redirect('Jaguar/result');		
			}
		}
    }

}
